<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        .mask {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(0, 0, 0, .3);
            display: none;
        }

        .menu {
            padding: 20px;
            border-radius: 6px;
            box-shadow: 0 0 4px 2px #ccc;
            position: absolute;
            background-color: #fff;
        }

        ul {
            list-style: none;
        }

        li {
            margin-bottom: 10px;
            padding: 10px;
            border-radius: 4px;
            border: 1px solid #ccc;
            cursor: pointer;
        }
    </style>
</head>

<body>
    <div class="mask">
        <div class="menu">
            <ul>
                <li>百度</li>
                <li>京东</li>
                <li>保存</li>
            </ul>
        </div>
    </div>
    <script>
        let mask = document.querySelector('.mask')
        let menu = document.querySelector('.menu')
        document.oncontextmenu = function (e) {
            e.preventDefault();
            let x = e.clientX, y = e.clientY;
            mask.style.display = 'block';
            menu.style.top = y + 'px';
            menu.style.left = x + 'px';
        }
        mask.onclick = function () {
            mask.style.display = '';
        }
        menu.onclick = function (e) {
            e.stopPropagation();
        }
    </script>
</body>

</html>